<template>
  <div style="padding-left:15px;">
    <div>
      <!--表格渲染-->
      <el-table ref="mainTable" class="tl-table" v-loading="loading" :data="datas" style="width: 100%;" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName" :default-sort="{ prop: 'id', order: 'ascending' }">
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="title" label="名称" width="300px" sortable="custom" sort-by="title" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="relationsystem" label="关联系统" width="150px" sortable="custom" sort-by="relationsystem" align="center" header-align="center"></el-table-column>
        <el-table-column prop="lastupdatetime" label="文件最后更新时间" sortable="custom" sort-by="lastupdatetime" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="操作" width="100px" v-slot="scope" fixed="right">
          <el-button type="text" icon="el-icon-document" @click="openIframeDialog('fileIframe', scope.row)">查看文件</el-button>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
    </div>
    <file-iframe ref="fileIframe" @refresh="doRefresh"></file-iframe>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from "@tapui/mixins/mixin_list"
/** 子组件 */
import fileIframe from "./iframe"
import { validateNull } from "@tapui/utils/validate"
import { mapGetters } from 'vuex'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from "@tapui/utils/http"
export default {
  mixins: [mixin_list],
  components: { fileIframe },
  data() {
    return {
      description: "流程文件列表",
      urlPrefix: "/base/processDocumentInfo/",
      url: {
        // queryCodeList: '/base/flowFile/dataCodeList'
        list: '/base/processDocumentInfo/refList'
      },
      // 排序参数
      sorterInfo: {
        sidx: "sortcode",
        sord: "asc"
      },
      isQueryOnCreated: false,
      display: 'none',
      fileId: 0
    }
  },
  props: {
    category: {
      default: '',
      type: String
    }
  },
  computed: {
    ...mapGetters(['user', 'token', 'theme'])
  },
  methods: {
    beforeLoadData() {
      this.queryParam.qry_category = this.category
      this.queryParam.qry_enabled = 1
      return true
    },
    openIframeDialog(fileIframe, url) {
      if (url.relationsystem === '0') {
        this.$refs.fileIframe.visible = true
        this.$refs.fileIframe.fileUrl = url.relationsourceid
      } else {
        window.open(process.env.CDMC_API + '/tempFilePreview?id=' + url.relationsourceid + '&token=' + this.token, '_blank')
      }
    },
    cancel() {
      this.display = 'none'
    }
  }
}
</script>

<style scoped></style>
